package com.nbsaas.boot.manufacturing.data.entity;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import lombok.Data;
import org.hibernate.annotations.Comment;

import java.math.BigDecimal;

@CreateByUser
@ComposeView
@Data
@FormAnnotation(title = "物料", model = "物料")
@Entity
@Table(name = "bs_material")
@Comment("物料表")
public class Material extends AbstractEntity {

    @Comment("物料编码")
    @SearchItem(name = "materialCode", key = "materialCode", label = "物料编码")
    @FormField(title = "物料编码", sortNum = "1", grid = true, required = true)
    @Column(length = 50, nullable = false, unique = true)
    private String materialCode;

    @Comment("物料名称")
    @SearchItem(name = "name", key = "name", label = "物料名称")
    @FormField(title = "物料名称", sortNum = "2", grid = true, required = true)
    @Column(length = 200, nullable = false)
    private String name;

    @Comment("物料规格")
    @FormField(title = "物料规格", sortNum = "3", grid = true)
    @Column(length = 200)
    private String specification;

    @Comment("物料类型")
    @FormField(title = "物料类型", sortNum = "4", grid = true, type = InputType.select)
    @Column(length = 50)
    private String materialType; // RAW-原材料, SEMI_FINISHED-半成品, FINISHED-成品, AUXILIARY-辅助材料

    @Comment("物料分类ID")
    @FormField(title = "物料分类", sortNum = "5", grid = true, type = InputType.select)
    private Long categoryId;

    @Comment("计量单位")
    @FormField(title = "计量单位", sortNum = "6", grid = true)
    @Column(length = 20)
    private String unit;

    @Comment("标准成本")
    @FormField(title = "标准成本", sortNum = "7", grid = true, type = InputType.el_input_number)
    @Column(precision = 10, scale = 2)
    private BigDecimal standardCost;

    @Comment("采购价格")
    @FormField(title = "采购价格", sortNum = "8", grid = true, type = InputType.el_input_number)
    @Column(precision = 10, scale = 2)
    private BigDecimal purchasePrice;

    @Comment("销售价格")
    @FormField(title = "销售价格", sortNum = "9", grid = true, type = InputType.el_input_number)
    @Column(precision = 10, scale = 2)
    private BigDecimal salePrice;

    @Comment("当前库存")
    @FormField(title = "当前库存", sortNum = "10", grid = true, type = InputType.el_input_number, sort = true)
    private Integer currentStock;

    @Comment("安全库存")
    @FormField(title = "安全库存", sortNum = "11", grid = true, type = InputType.el_input_number)
    private Integer safetyStock;

    @Comment("最大库存")
    @FormField(title = "最大库存", sortNum = "12", grid = true, type = InputType.el_input_number)
    private Integer maxStock;

    @Comment("最小订购量")
    @FormField(title = "最小订购量", sortNum = "13", grid = true, type = InputType.el_input_number)
    private Integer minOrderQuantity;

    @Comment("供应商ID")
    @FormField(title = "供应商", sortNum = "14", grid = true, type = InputType.select)
    private Long supplierId;

    @Comment("供应商编码")
    @FormField(title = "供应商编码", sortNum = "15", grid = true)
    @Column(length = 50)
    private String supplierCode;

    @Comment("供应商物料编码")
    @FormField(title = "供应商物料编码", sortNum = "16", grid = true)
    @Column(length = 50)
    private String supplierMaterialCode;

    @Comment("采购提前期(天)")
    @FormField(title = "采购提前期(天)", sortNum = "17", grid = true, type = InputType.el_input_number)
    private Integer leadTime;

    @Comment("质量等级")
    @FormField(title = "质量等级", sortNum = "18", grid = true, type = InputType.select)
    @Column(length = 20)
    private String qualityGrade; // A-优, B-良, C-一般, D-差

    @Comment("物料状态")
    @FormField(title = "物料状态", sortNum = "19", grid = true, type = InputType.select)
    @Column(length = 20)
    private String status; // ACTIVE-启用, INACTIVE-停用, DISCONTINUED-停产

    @Comment("是否关键物料")
    @FormField(title = "是否关键物料", sortNum = "20", grid = true, type = InputType.select)
    private Boolean isCritical;

    @Comment("是否危险品")
    @FormField(title = "是否危险品", sortNum = "21", grid = true, type = InputType.select)
    private Boolean isDangerous;

    @Comment("是否易腐品")
    @FormField(title = "是否易腐品", sortNum = "22", grid = true, type = InputType.select)
    private Boolean isPerishable;

    @Comment("保质期(天)")
    @FormField(title = "保质期(天)", sortNum = "23", grid = true, type = InputType.el_input_number)
    private Integer shelfLife;

    @Comment("重量(克)")
    @FormField(title = "重量(克)", sortNum = "24", grid = true, type = InputType.el_input_number)
    private Integer weight;

    @Comment("体积(立方厘米)")
    @FormField(title = "体积(立方厘米)", sortNum = "25", grid = true, type = InputType.el_input_number)
    private Integer volume;

    @Comment("物料图片")
    @FormField(title = "物料图片", sortNum = "26", type = InputType.image)
    @Column(length = 500)
    private String image;

    @Comment("技术参数")
    @FormField(title = "技术参数", sortNum = "27", type = InputType.richText, col = 23)
    @Column(columnDefinition = "TEXT")
    private String technicalParameters;

    @Comment("质量要求")
    @FormField(title = "质量要求", sortNum = "28", type = InputType.richText, col = 23)
    @Column(columnDefinition = "TEXT")
    private String qualityRequirements;

    @Comment("存储要求")
    @FormField(title = "存储要求", sortNum = "29", type = InputType.richText, col = 23)
    @Column(columnDefinition = "TEXT")
    private String storageRequirements;

    @Comment("备注")
    @FormField(title = "备注", sortNum = "30", type = InputType.richText, col = 23)
    @Column(length = 1000)
    private String note;
} 